import request from "@/utils/request.js"

/**
 * 保存答题
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const saveAnswer = (data) => {
  return request.post('/user/answer', data, {
    timeout: 60000
  })
}

/**
 * 根据id获取答题记录
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryAnswerById = (data) => {
  return request.get('/user/answer/' + data)
}

/**
 * 分页查询答题记录
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryAnswerRecordsPage = (data) => {
  return request.post('/user/answer/page', data)
}

/**
 * 删除答题记录
 * @param id
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteAnswerRecords = (id, data) => {
  return request.delete('/user/answer/' + id, {data})
}

/**
 * 导出答题记录
 * @param id
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const exportAnswerRecords = (id, data) => {
  return request.post('/user/answer/export/' + id, data, { responseType: 'blob' })
}

/**
 * 查询用户答题记录
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const queryUserAnswerRecordsPage = (data) => {
  return request.post('/user/answer/user', data)
}
